<?php

namespace App\Models\FeishuCallingCard;

use App\Models\BaseModel;

class FeishuCallingCardsArticle extends BaseModel
{
    protected $table = 'feishu_calling_cards_articles';

    protected $casts = [
        'extra' => 'array'
    ];

    protected $fillable = [
        'type',
        'name',
        'content',
        'originalImage',
        'thumbImage',
        'url',
        'weight',
        'status',
        'extra'
    ];

    const STATUS_ON  = 1;
    const STATUS_OFF = 0;


    const ARTICLE_TYPE_1 = 1;//加盟商说
    const ARTICLE_TYPE_2 = 2;//品牌介绍

    const ARTICLE_TYPE_3  = 3;//首页轮播图
    const ARTICLE_TYPE_4  = 4;//主打产品
    const ARTICLE_TYPE_5  = 5;//明星门店秀
    const ARTICLE_TYPE_6  = 6;//夸父荣誉
    const ARTICLE_TYPE_7  = 7;//加盟案例
    const ARTICLE_TYPE_8  = 8;//采访视频
    const ARTICLE_TYPE_9  = 9;//新闻
    const ARTICLE_TYPE_10 = 10;//品牌产品

    const ARTICLE_PC_TYPE_31 = 31;//pc-首页轮播图
    const ARTICLE_PC_TYPE_32 = 32;//pc-主打产品
    const ARTICLE_PC_TYPE_33 = 33;//pc-明星门店秀
    const ARTICLE_PC_TYPE_34 = 34;//pc-夸父荣誉
    const ARTICLE_PC_TYPE_35 = 35;//pc-采访视频
    const ARTICLE_PC_TYPE_36 = 36;//pc-新闻资讯
    const ARTICLE_PC_TYPE_37 = 37;//pc-品牌产品
    const ARTICLE_PC_TYPE_38 = 38;//pc-加盟案例
    const ARTICLE_PC_TYPE_39 = 39;//pc-广告位图片配置

    const ARTICLE_TYPE_40 = 40;// 企微文章

    const ARTICLE_TYPE_MAP = [
        self::ARTICLE_TYPE_1     => "加盟商说",
        self::ARTICLE_TYPE_2     => "品牌介绍",

        /***************    h5分类    ****************/
        self::ARTICLE_TYPE_3     => "H5-首页轮播图",
        self::ARTICLE_TYPE_4     => "H5-主打产品",
        self::ARTICLE_TYPE_5     => "H5-明星门店秀",
        self::ARTICLE_TYPE_6     => "H5-夸父荣誉",
        self::ARTICLE_TYPE_7     => "H5-加盟案例",
        self::ARTICLE_TYPE_8     => "H5-采访视频",
        self::ARTICLE_TYPE_9     => "H5-新闻",
        self::ARTICLE_TYPE_10    => "H5-品牌产品",

        /***************    pc分类    ****************/
        self::ARTICLE_PC_TYPE_31 => "pc-首页轮播图",
        self::ARTICLE_PC_TYPE_32 => "pc-主打产品",
        self::ARTICLE_PC_TYPE_33 => "pc-明星门店秀",
        self::ARTICLE_PC_TYPE_34 => "pc-夸父荣誉",
        self::ARTICLE_PC_TYPE_35 => "pc-采访视频",
        self::ARTICLE_PC_TYPE_36 => "pc-新闻资讯",
        self::ARTICLE_PC_TYPE_37 => "pc-品牌产品",
        self::ARTICLE_PC_TYPE_38 => "pc-加盟案例",
        self::ARTICLE_PC_TYPE_39 => "pc-广告位图片配置",

        self::ARTICLE_TYPE_40 => '企微文章',
    ];

    const ARTICLE_FROM_1    = 1;
    const ARTICLE_FROM_2    = 2;
    const ARTICLE_FROM_TEXT = [
        self::ARTICLE_FROM_1 => [
            self::ARTICLE_TYPE_1  => "加盟商说",
            self::ARTICLE_TYPE_2  => "品牌介绍",
            self::ARTICLE_TYPE_40 => '企微文章',
        ],
        self::ARTICLE_FROM_2 => [
            /***************    h5分类    ****************/
            self::ARTICLE_TYPE_3     => "首页轮播图",
            self::ARTICLE_TYPE_4     => "主打产品",
            self::ARTICLE_TYPE_5     => "明星门店秀",
            self::ARTICLE_TYPE_6     => "夸父荣誉",
            self::ARTICLE_TYPE_7     => "加盟案例",
            self::ARTICLE_TYPE_8     => "采访视频",
            self::ARTICLE_TYPE_9     => "新闻",
            self::ARTICLE_TYPE_10    => "品牌产品",
            /***************    pc分类    ****************/
            self::ARTICLE_PC_TYPE_31 => "pc-首页轮播图",
            self::ARTICLE_PC_TYPE_32 => "pc-主打产品",
            self::ARTICLE_PC_TYPE_33 => "pc-明星门店秀",
            self::ARTICLE_PC_TYPE_34 => "pc-夸父荣誉",
            self::ARTICLE_PC_TYPE_35 => "pc-采访视频",
            self::ARTICLE_PC_TYPE_36 => "pc-夸父新闻",
            self::ARTICLE_PC_TYPE_37 => "pc-品牌产品",
            self::ARTICLE_PC_TYPE_38 => "pc-加盟案例",
            self::ARTICLE_PC_TYPE_39 => "pc-广告位图片配置",
        ],
    ];

    public static function boot()
    {
        parent::boot();
        static::saving(function ($model) {
            if (null === $model->extra) {
                $model->extra = '{}';
            }
            if (is_array($model->extra) || is_object($model->extra)) {
                $model->extra = json_encode($model->extra, JSON_UNESCAPED_UNICODE);
            }
        });
    }
}
